package cn.net.pap.pinyincut.analysis;

import cn.net.pap.pinyincut.core.PinyinCutAnalyzer;
import org.apache.lucene.analysis.Analyzer;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.AbstractIndexAnalyzerProvider;
import org.elasticsearch.index.analysis.AnalyzerProvider;

public class PinyinCutAnalyzerProvider extends AbstractIndexAnalyzerProvider<PinyinCutAnalyzer> {
    private final PinyinCutAnalyzer analyzer;

    public PinyinCutAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings, boolean indexMode) {
        super(indexSettings, name, settings);

        analyzer = new PinyinCutAnalyzer();
    }

    public static AnalyzerProvider<? extends Analyzer> getAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings) {
        return new PinyinCutAnalyzerProvider(indexSettings, env, name, settings, false);
    }


    @Override
    public PinyinCutAnalyzer get() {
        return analyzer;
    }
}
